from utilities.enums import TaskType, EXTaskType
from utilities import event_parser
from utilities import scanner


SECURITY_EVENT = {
    'job_name': 'appscan',
    'event_parser': event_parser.SecurityEventParser,
    'period_scheduler': scanner.SchedulerServer,
}

VUL = {
    'job_name': 'kscan',
    'event_parser': event_parser.VulParser,
    'period_scheduler': scanner.VulScheduler,
}

AVAILABILITY = {
    'job_name': 'site_info',
    'event_parser': event_parser.AvailabilityParser,
    'period_scheduler': scanner.AvailabilityScheduler,
}


TARGET_INFO = {
    'job_name': 'site_info',
    'event_parser': event_parser.TargetInfoParser,
    'period_scheduler': scanner.TargetInfoScheduler,
}

RISK_LINK = {
    'job_name': 'risk_link',
    'event_parser': event_parser.RiskLinkParser,
    'period_scheduler': scanner.RiskLinkScheduler,
}


VUL_VERIFICATION_TASK = {
    'job_name': 'kscan',
    'event_parser': None,
    'scheduler': scanner.VulVerificationScheduler,
}

CHANGE_CHECK = {
    'job_name': 'change_check',
    'event_parser': event_parser.ChangeCheckParser,
    'period_scheduler': scanner.ChangeCheckScheduler,
}

CHANGE_CHECK_CONFIG = {
    'job_name': 'change_check',
    'event_parser': None,
    'period_scheduler': scanner.ChangeCheckConfigScheduler,
}


TASK_CONFIG = {
    TaskType.securityEvent.value: SECURITY_EVENT,
    TaskType.vul.value: VUL,
    TaskType.availability.value: AVAILABILITY,
    TaskType.risk_link.value: RISK_LINK,
    TaskType.change_check.value: CHANGE_CHECK,
}

EX_TASK_CONFIG = {
    EXTaskType.target_info.value: TARGET_INFO,
    EXTaskType.vul_verification_task: VUL_VERIFICATION_TASK,
    EXTaskType.change_check_config.value: CHANGE_CHECK_CONFIG,
}


JOB_NAME_MAP = {k: v.get('job_name') for k, v in TASK_CONFIG.items()}
PARSER_MAP = {k: v.get('event_parser') for k, v in TASK_CONFIG.items()}
PERIOD_SCANNER_MAP = {k: v.get('period_scheduler') for k, v in TASK_CONFIG.items()}
TASK_TYPE_TUPLE = tuple(item for item in TASK_CONFIG.keys())
EX_TASK_TYPE_TUPLE = tuple(item for item in EX_TASK_CONFIG.keys())
